#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

int main() {
    srand(time(0));
    int secretNum = rand() % 100 + 1;
    int guess;
    int attempts = 0;

    while (true) {
        cout << "请输入一个1到100之间的数字：";
        cin >> guess;
        attempts++;
        if (guess < secretNum) {
            cout << "太小了" << endl;
        } else if (guess > secretNum) {
            cout << "太大了" << endl;
        } else {
            cout << "恭喜你，猜对了。" << endl;
            cout << "你总共猜了 " << attempts << " 次。" << endl;
            break;
        }
    }
    return 0;
}